/*
 * pid.h
 *
 *  Created on: 2022年1月6日
 *      Author: paper
 */

#ifndef CODE_PID_H_
#define CODE_PID_H_
#include "zf_common_headfile.h"

typedef struct {
    float target_val;             //目标值，相当于SetValue
    float Kp;                       //比例系数Proportional
    float Ki;                       //积分系数Integral
    float Kd;                       //微分系数Derivative
    float Ek;                       //当前误差
    float Ek1;                      //前一次误差 e(k-1)
    float Ek2;                      //再前一次误差 e(k-2)？（积分累积项）
    float OUT;                      //PID输出
    float integral;    // 积分项

    float                out_p;  //KP输出
       float                out_i;  //KI输出
       float                out_d;  //KD输出
       float                out;    //pid输出

       float                integrator; //< 积分值
       float                last_error; //< 上次误差
       float                last_derivative;//< 上次误差与上上次误差之差

} PID_IncTypeDef;


void PID_Inc_Init(PID_IncTypeDef* sptr, float kp, float ki, float kd);
float Positional_PID(PID_IncTypeDef* PID, float SetValue, float ActualValue, float Max_I);
float PidIncCtrl(PID_IncTypeDef *PID, float error);
void PID_param_init(void);

extern PID_IncTypeDef roll_angle_wheel, roll_anglespeed_wheel, roll_speed_wheel;
extern PID_IncTypeDef  bdc_speed_wheel, bdc_banlance_wheel,bdc_wheel,bdc_speed_wheel1;
extern PID_IncTypeDef bldc_yaw_anglespeed_wheel, bldc_yaw_angle_wheel, bldc_yaw_speed_wheel ;
extern float pidout_1f, pidout_2f, pidout_3f, pidout_4f, pidout_5f, pidout_6f;


#endif /* CODE_PID_H_ */
